package org.jash.shop2112.entity

import android.content.Context
import android.content.Intent
import android.widget.Toast
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.annotations.JsonAdapter
import org.jash.shop2112.product.DetailActivity
import org.jash.shop2112.utils.StringToMap
import org.jash.shop2112.utils.bus

@Entity
data class Goods (
    val category_id: Int,
    val goods_banner: String,
    val goods_code: String,
    val goods_default_icon: String,
    val goods_default_price: Float,
    val goods_desc: String,
    val goods_detail_one: String,
    val goods_detail_two: String,
    val goods_sales_count: Int,
    val goods_stock_count: Int,
    @PrimaryKey
    val id: Int
) {
    @Ignore
    val bannerList: List<String> = listOf()
    @JsonAdapter(StringToMap::class)
    @Ignore
    val goods_attribute: Map<String, List<String>>? = null
    fun showDetail() {
        ARouter.getInstance()
            .build("/shop/detail")
            .withInt("id", id)
            .navigation()
    }
}